# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=psxstub
_mingw_suff=midipix-cross
_base_ver=0.0
pkgname=("${_mingw_suff}-${_realname}")
provides=("${_mingw_suff}-psxscl")
conflicts=("${_mingw_suff}-psxscl")
pkgver=0.0.7.92a6ceb
pkgrel=1
pkgdesc="Stub for the midipix system call layer"
arch=('i686' 'x86_64')
url="https://midipix.org/"
groups=("${_mingw_suff}-toolchain" "${_mingw_suff}")
depends=("zlib")
makedepends=("${_mingw_suff}-gcc" 'make')
options=('!strip' 'staticlibs' '!emptydirs' '!buildflags')
source=("${_realname}"::"git+git://midipix.org/psxstub")
sha256sums=('SKIP')

#not supported yet
#i686-nt32-midipix
_targets="x86_64-nt64-midipix"

pkgver() {
  cd "$srcdir/$_realname"
  printf "%s.%s.%s" "${_base_ver}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "$srcdir/$_realname"
  for _target in ${_targets}; do
    make clean
    make TARGET="${_target}"

    #hack because -mout-implib is not working on cygwin host binutils
    ${_target}-dlltool -D libpsxscl.so -l libpsxscl.lib.a
  done
}


package() {
  cd "$srcdir/$_realname"
  for _target in ${_targets}; do
    make TARGET="${_target}" DESTDIR="${pkgdir}/opt/${_target}" install
  done
}
